<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>新增积分卡</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<jsp:include page="/page/head.jsp"></jsp:include>
	<script type="text/javascript">
		//保存信息
		function save(){
			$('#saveBtn').attr('disabled','disabled');
			
			var number = escape(escape($('#number').val()));                     //获取number值
			var cardOne = escape(escape($('#cardOne').val()));                   //获取cardOne值
			var cardTwo = escape(escape($('#cardTwo').val()));                   //获取cardTwo值
			var cardThree = escape(escape($('#cardThree').val()));               //获取cardThree值
			var score = escape(escape($('#score').val()));                       //获取score值
			var effectiveTimeStart = $('#effectiveTimeStart').datebox('getValue');
			var effectiveTimeEnd = $('#effectiveTimeEnd').datebox('getValue');         //获取effectiveTimeEnd值
			
			if($('#fm').form('validate')){
				$.ajax({
					  url:path +"/scoreCard/save.do?number="+number+"&cardOne="+cardOne+"&cardTwo="+cardTwo+"&cardThree="+cardThree+"&score="+score+"&effectiveTimeStart="+effectiveTimeStart+"&effectiveTimeEnd="+effectiveTimeEnd,
					  success: function(data) {
						  if(data == "1"){
							  window.location = path+"/scoreCard/scoreCardMgr.do";
						   }else{
							   alertBox("添加失败！");
						   } 
					  }
				});
			}
		}
		
		//撤销回退
		function callback(){
			window.location = path+"/scoreCard/scoreCardMgr.do";
		}
		
		
		
		//验证部分
		//卡号长度验证
		
		$.extend($.fn.validatebox.defaults.rules, { 
			one:{
				 validator: function (value) {
			            return value.length == 2;
			        },
			        message: '只能输入2位'
			},
			two:{
				 validator: function (value) {
			            return value.length == 4;
			        },
			        message: '只能输入4位'
			},
			three:{
				 validator: function (value) {
			            return value.length == 5;
			        },
			        message: '只能输入5位'
			}
		});
		
	</script>
  </head>
  
  <body>
   <div class="right">
		<h1><b>新增积分卡</b><span><img src="<%=basePath%>images/right_h1bg2.jpg" width="3" height="29" /></span></h1>
		<div class="ri_main">
			<form id="form">
				<table width="100%" border="0" cellspacing="1" cellpadding="8" style="background:#d9d9d9;">
				  <tr>
				    <td width="15%" align="center" bgcolor="#FFFFFF">数量:</td>
				    <td width="40%" bgcolor="#FFFFFF" align="left"><label for="textfield"></label>
				      <input id="number" name="number" class="easyui-validatebox" required="true" style="width:200px;" />
				    </td>
				  </tr>
				  <tr>
				    <td align="center" bgcolor="#FFFFFF">积分卡号:</td>
				    <td bgcolor="#FFFFFF" align="left" >
				    	<input validType="one" id="cardOne" name="cardOne" class="easyui-validatebox" required="true" style="width:50px;"  />-
				    	<input validType="two" id="cardTwo" name="cardTwo" class="easyui-validatebox" required="true" style="width:50px;"  />-
				    	<input validType="three" id="cardThree" name="cardThree" class="easyui-validatebox" required="true" style="width:50px;"  />
				    	<lable>卡号规则 :CS 2012 00000</lable>
				    </td>
				  </tr>
				  <tr>
				    <td align="center" bgcolor="#FFFFFF">积分:</td>
				    <td bgcolor="#FFFFFF" align="left">
				    	<input id="score" name="score" class="easyui-validatebox" required="true" style="width:200px;" /> *
				    </td>
				  </tr>
				  <tr>
				    <td align="center" bgcolor="#FFFFFF">有效时间:</td>
				    <td bgcolor="#FFFFFF" align="left">
				    	<input id="effectiveTimeStart" name="effectiveTimeStart" class="easyui-datebox" required="true" style="width:200px;" />-
				    	<input id="effectiveTimeEnd" name="effectiveTimeEnd" class="easyui-datebox" required="true" style="width:200px;" />
				    </td>
				  </tr>
				  <tr>
				    <td bgcolor="#FFFFFF" colspan="2" align="center">
				    	<a href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton" iconCls="icon-ok" onclick="save()">保存</a>
						<a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-cancel" onclick="callback()">取消</a>
				    </td>
				  </tr>
				</table>
			</form>
		</div>
	</div>
  </body>
</html>
